//
//  NSAttributedString+Custom.m
//  FashionTech
//
//  Created by JackieYip on 2016/12/21.
//  Copyright © 2016年 mondial-d. All rights reserved.
//

#import "NSAttributedString+Custom.h"

@implementation NSAttributedString (Custom)
+ (NSAttributedString *)attributedStringWithDeletedLineForString:(NSString *)string
{
    return [self attributedStringWithDeletedLineForString:string lineColor:[UIColor colorWithWhite:0 alpha:1.0]];
}

+ (NSAttributedString *)attributedStringWithDeletedLineForString:(NSString *)string lineColor:(UIColor *)lineColor
{
    NSUInteger length = [string length];
    NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:string];
    [attri addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlineStyleThick | NSUnderlinePatternSolid) range:NSMakeRange(0, length)];
    [attri addAttribute:NSStrikethroughColorAttributeName value:lineColor range:NSMakeRange(0, length)];
    return attri;
}

+ (NSAttributedString *)attributesDictionaryWithShadowForString:(NSString *)string shadowColor:(UIColor *)shadowColor
{
    NSUInteger length = [string length];
    NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:string];
    
    NSShadow *shadow = [[NSShadow alloc] init];
    shadow.shadowBlurRadius = 2.0;
    shadow.shadowOffset = CGSizeMake(0, 1);
    shadow.shadowColor = shadowColor;
    [attri addAttribute:NSShadowAttributeName value:shadow range:NSMakeRange(0, length)];
    return attri;
}

+ (NSAttributedString *)attributedStringWithUnderlineForString:(NSString *)string range:(NSRange)range
{
    NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:string];
    [attri addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:range];
    return attri;
}
@end
